GDK/Win32: Cleanup and further fix OpenGL/ES glitches
authorChun-wei Fan <fanchunwei@src.gnome.org>
Wed, 20 Jun 2018 09:27:30 +0000 (17:27 +0800)
committerChun-wei Fan <fanchunwei@src.gnome.org>
Thu, 28 Jun 2018 07:33:42 +0000 (15:33 +0800)
We also need to invalidate the OpenGL/ES window when we resize the
window via a mouse drag operation, so that we don't get glitches in such
situations, because they are not covered in GdkWindow's
impl_class->move_resize().

Make sure that we only force the invalidation when necessary (as it is
expensive), and clean up the gdkevents-win32.c code so that we include
gdkglcontext-win32.h in the right place instead of using an extern, as
we need to invalidate the window accordingly.

gdk/win32/gdkevents-win32.c
gdk/win32/gdkwindow-win32.c

index f153dcba3d3f0c1113e13324753f5f06c4e963a2..c050b9d64c4173a3197d9333fae7842e701885c2 100644 (file)
@@ -51,6 +51,7 @@
 #include "gdkmonitorprivate.h"
 #include "gdkwin32.h"
 #include "gdkkeysyms.h"
+#include "gdkglcontext-win32.h"
 #include "gdkdevicemanager-win32.h"
 #include "gdkdeviceprivate.h"
 #include "gdkdevice-wintab.h"
@@ -93,8 +94,6 @@
  * Private function declarations
  */
 
-extern void _gdk_win32_window_invalidate_egl_framebuffer (GdkWindow *window);
-
 #define SYNAPSIS_ICON_WINDOW_CLASS "SynTrackCursorWindowClass"
 
 static gboolean gdk_event_translate (MSG        *msg,
@@ -3342,6 +3341,8 @@ gdk_event_translate (MSG  *msg,
             {
               MINMAXINFO our_mmi;
 
+              _gdk_win32_window_invalidate_egl_framebuffer (window);
+
               if (_gdk_win32_window_fill_min_max_info (window, &our_mmi))
                 {
                   windowpos = (WINDOWPOS *) msg->lParam;
index 3535859194fde7f3ce5be5d0a4a67dc10b5102c7..28f2b7696d04be0f5e62bc4f0fa6d6bc3a49ed8c 100644 (file)
@@ -1701,8 +1701,6 @@ gdk_win32_window_move_resize (GdkWindow *window,
   window_impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
   window_impl->inhibit_configure = TRUE;
 
-  _gdk_win32_window_invalidate_egl_framebuffer (window);
-
   /* We ignore changes to the window being moved or resized by the
      user, as we don't want to fight the user */
   if (GDK_WINDOW_HWND (window) == _modal_move_resize_window)
@@ -1714,6 +1712,7 @@ gdk_win32_window_move_resize (GdkWindow *window,
     }
   else
     {
+      _gdk_win32_window_invalidate_egl_framebuffer (window);
       if (with_move)
        {
          gdk_win32_window_move_resize_internal (window, x, y, width, height);
@@ -4778,6 +4777,9 @@ gdk_win32_window_end_move_resize_drag (GdkWindow *window)
   GdkWindowImplWin32 *impl = GDK_WINDOW_IMPL_WIN32 (window->impl);
   GdkW32DragMoveResizeContext *context = &impl->drag_move_resize_context;
 
+  if (context->op == GDK_WIN32_DRAGOP_RESIZE)
+    _gdk_win32_window_invalidate_egl_framebuffer (window);
+
   context->op = GDK_WIN32_DRAGOP_NONE;
 
   gdk_device_ungrab (context->device, GDK_CURRENT_TIME);
@@ -5277,8 +5279,6 @@ gdk_win32_window_maximize (GdkWindow *window)
                           GDK_WINDOW_HWND (window),
                           _gdk_win32_window_state_to_string (window->state)));
 
-  _gdk_win32_window_invalidate_egl_framebuffer (window);
-
   if (GDK_WINDOW_IS_MAPPED (window))
     GtkShowWindow (window, SW_MAXIMIZE);
   else
@@ -6040,7 +6040,6 @@ GtkShowWindow (GdkWindow *window,
     case SW_SHOWNA:
     case SW_SHOWNOACTIVATE:
     case SW_SHOWNORMAL:
-      _gdk_win32_window_invalidate_egl_framebuffer (window);
 
       if (IsWindowVisible (hwnd))
         break;